/*******************************************************************************
**
** Copyright (c) 2011 - The OWE Team
**
** This file is part of OWE.
**
** OWE is a free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; version
** version 2.1 of the License.
**
** OWE is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with OWE. If not, see <http://www.gnu.org/licenses/>.
**
*******************************************************************************/

#ifndef WIDGETELEMENT_H
#define WIDGETELEMENT_H

#include <map>

#include <owe/element.h>

OWE_BEGIN_NAMESPACE

class AuthorElement;
class ContentElement;
class DescriptionElement;
class FeatureElement;
class IconElement;
class LicenseElement;
class NameElement;
class Node;
class PreferenceElement;
class UString;

typedef std::map<UString, FeatureElement *> FeatureElementList;
typedef std::map<UString, IconElement *> IconElementList;
typedef std::map<UString, PreferenceElement *> PreferenceElementList;

class OWE_EXPORT WidgetElement : public Element
{
public:
    WidgetElement(const Node *node);
    ~WidgetElement();

    bool addChild(Element *element);

    UString id() const { return m_id; }
    UString version() const { return m_version; }
    UString height() const { return m_height; }
    UString width() const { return m_width; }
    UString viewModes() const { return m_viewModes; }

    const NameElement *name(const char *locale = "") const;
    const DescriptionElement *description(const char *locale = "") const;
    const AuthorElement *author() const { return m_author; }
    const FeatureElementList feature() const { return m_feature; }
    const LicenseElement *license(const char *locale = "") const;
    const ContentElement *content() const { return m_content; }
    const IconElementList icon() const { return m_icon; }
    const PreferenceElementList preference() const { return m_preference; }

private:
    bool addName(NameElement *name);
    bool addDescription(DescriptionElement *name);
    bool addAuthor(AuthorElement *name);
    bool addFeature(FeatureElement *feature);
    bool addLicense(LicenseElement *license);
    bool addContent(ContentElement *content);
    bool addIcon(IconElement *icon);
    bool addPreference(PreferenceElement *preference);

    UString m_id;
    UString m_version;
    UString m_height;
    UString m_width;
    UString m_viewModes;

    std::map<UString, NameElement *> m_name;
    std::map<UString, DescriptionElement *> m_description;
    std::map<UString, FeatureElement *> m_feature;
    std::map<UString, LicenseElement *> m_license;
    std::map<UString, IconElement *> m_icon;
    std::map<UString, PreferenceElement *> m_preference;

    AuthorElement *m_author;
    ContentElement *m_content;
};

OWE_END_NAMESPACE

#endif // WIDGETELEMENT_H
